package com.woniu.controller;

import com.woniu.entity.Address;
import com.woniu.entity.Useraddress;
import com.woniu.service.UserAddressService;
import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/useraddress")
@RestController
public class UserAddressController {
    @Resource
    private UserAddressService userAddressService;

    @PostMapping("/addUserAddress")
    public ResponseUtil addUserAddress(@RequestBody Address useraddress){
        return userAddressService.addUserAddress(useraddress);
    }
    @GetMapping("/{userId}")
    public ResponseUtil findUserAddress(@PathVariable Integer userId){
        return userAddressService.findUserAddress(userId);
    }
    @PostMapping("/updateUserAddress")
    public ResponseUtil updateUserAddress(@RequestBody Address useraddress){
        return userAddressService.updateUserAddress(useraddress);
    }
    @DeleteMapping("/{addressId}")
    public ResponseUtil deleteUserAddress(@PathVariable Integer addressId){
        return userAddressService.deleteUserAddress(addressId);
    }
}
